<template>
  <div class="app-container home">
    <el-row v-hasRole="['rwork']" :gutter="40" class="panel-group">
      <el-col  :xs="12" :sm="12" :lg="8" class="card-panel-col">
          <div class="card-panel" @click="handleToListPage('jjbg')">
            <div class="card-panel-icon-wrapper icon-people">
              <svg-icon icon-class="peoples" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">
                计件报工
              </div>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="8" class="card-panel-col">
          <div class="card-panel" @click="handleToListPage('lgbg')">
            <div class="card-panel-icon-wrapper icon-people">
              <svg-icon icon-class="job" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">
                零工报工
              </div>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="8" class="card-panel-col">
          <div class="card-panel" @click="handleToListPage('bgcx')">
            <div class="card-panel-icon-wrapper icon-people">
              <svg-icon icon-class="search" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">
                报工查询
              </div>
            </div>
          </div>
        </el-col>
<!--        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel" @click="handleSetLineChartData('shoppings')">
            <div class="card-panel-icon-wrapper icon-shopping">
              <svg-icon icon-class="shopping" class-name="card-panel-icon" />
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">
                工资明细
              </div>
            </div>
          </div>
        </el-col> -->
    </el-row>

    <el-divider />
    <el-row :gutter="20">
      <el-col :xs="24" :sm="24" :md="12" :lg="14">
        <el-card class="update-log" :style="{height:'100%'}">
          <div slot="header" class="clearfix">
            <span>待办任务</span>
            <el-button  style="float: right; padding: 3px 0" type="text" @click="handleToListPage('db')">查看更多</el-button>
          </div>
          <div v-if="dbList==null||dbList.length==0">
            <el-empty  description="暂无待办"></el-empty>
          </div>
          <div class="body" v-for="item in dbList" :key="item.dbId" style="margin-bottom: 18px;">
            <el-link :underline="false" @click="handleDbClick(item.dbId)"> {{item.dbSubject }}</el-link>
          </div>
        </el-card>
      </el-col>


      <el-col :xs="24" :sm="24" :md="12" :lg="10">
        <el-card class="update-log" :body-style="{height:'100%'}">
          <div slot="header" class="clearfix">
            <span>通知公告</span>
            <el-button style="float: right; padding: 3px 0" type="text" @click="handleToListPage('gg')">查看更多</el-button>
          </div>
          <div v-if="ggList==null||ggList.length==0">
            <el-empty  description="暂无公告"></el-empty>
          </div>
          <div class="body" v-for="item in ggList" :key="item.noticeId" style="margin-bottom: 18px;">
              <el-link :underline="false" @click="handlePageClick(item.noticeId)"> {{item.noticeTitle }}</el-link>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import LineChart from './dashboard/LineChart'
import { listDbinfo } from "@/api/sl/dbinfo";
import { listNotice} from "@/api/system/notice";

export default {
  name: "Index",
  components: {
    LineChart,
  },
  data() {
   return {
     dbList:null,
     ggList:null
   }
  },
  created(){
    var dbObj = {};
    dbObj.pageNum = 1;
    dbObj.pageNum = 10;
    dbObj.isDb = '0';
    listDbinfo(dbObj).then(response => {
        this.dbList = response.rows;
    });
    var ggObj = {};
    ggObj.pageNum = 1;
    ggObj.pageNum = 10;
    listNotice(ggObj).then(response => {
        this.ggList = response.rows;
    });
  },
  methods: {
    handleToListPage(type){
      if(type==='db'){
        this.$router.push({ path: "db/dbinfo", query: {isDb: "0"} });
      }else if(type==='gg'){
        this.$router.push({ path: "hb/notice"});
      }else if(type==='jjbg'){
        this.$router.push({ path: "bg/rwork"});
      }else if(type==='lgbg'){
        this.$router.push({ path: "bg/oddjob"});
      }else if(type==='bgcx'){
        this.$router.push({ path: "hrwork/rfwork"});
      }
    },
    handlePageClick(id){
      this.$router.push({ path: "hb/notice" });
    },
    handleDbClick(id){
      this.$router.push({ path: "db/dbinfo", query: {isDb: "0"} });
    },

  }
};
</script>

<style lang="scss" scoped>
.el-card{
  height: 100%;
}
.panel-group {
  margin-top: 18px;

  .card-panel-col {
    margin-bottom: 32px;
  }

  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      .icon-people {
        background: #40c9c6;
      }

      .icon-message {
        background: #36a3f7;
      }

      .icon-money {
        background: #f4516c;
      }

      .icon-shopping {
        background: #34bfa3
      }
    }

    .icon-people {
      color: #40c9c6;
    }

    .icon-message {
      color: #36a3f7;
    }

    .icon-money {
      color: #f4516c;
    }

    .icon-shopping {
      color: #34bfa3
    }

    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 48px;
    }

    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 26px;
      margin-left: 0px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
      }
    }
  }
}

@media (max-width:550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
</style>
